﻿using System;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace Assist
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class YJKCommandAuto : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			this.m_cmdData = cmdData;
			this.m_uiApp = cmdData.Application;
			this.m_uiDoc = this.m_uiApp.ActiveUIDocument;
			this.m_app = this.m_uiApp.Application;
			this.m_doc = this.m_uiDoc.Document;
			Transaction transaction = new Transaction(this.m_doc, this.ToString());
			transaction.Start();
			Result result = this.YJKExcute(cmdData, ref message, elements);
			bool flag = result == 0;
			if (flag)
			{
				transaction.Commit();
			}
			else
			{
				transaction.RollBack();
			}
			return result;
		}

		protected virtual Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public ExternalCommandData m_cmdData;

		public UIApplication m_uiApp;

		public UIDocument m_uiDoc;

		public Application m_app;

		public Document m_doc;

		protected static double precision = 1E-06;
	}
}
